package sg.edu.nus.iss.ooad.jass.ui.widget;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Label;
import java.awt.Panel;



/**
 *
 * Template Panel for JASS.
 *
 * @author Isak Rabin (HT082193M)
 * @version 1.0
 * @since 1.0
 *
 * Development Environment : Netbeans IDE v6.7
 * Name of the File        : JASSRegularPanel.java
 * Creation / Modification History
 *         Isak Rabin        03-Oct-2009        Created
 *
 */
public class JASSRegularPanel extends Panel {

        private static final long serialVersionUID = -592625134395195348L;
        private String title = "";
        private Label labelPanelTitle = null;
        private Panel panelContent = null;

        /**
         * Constructor
         * @param title Panel title.
         */
        public JASSRegularPanel(String title) {
                super();
                this.title = title;
                initComponents();
        }

        /**
         * Constructor
         * @param title Title of Panel.
         * @param dimension Dimension of Panel
         */
        public JASSRegularPanel(String title, Dimension dimension) {
                this(title);
                setSize(dimension);
        }

        /**
         * Constructor
         * @param title Title of Panel.
         * @param height Height of Panel.
         * @param weight Width of Panel
         */
        public JASSRegularPanel(String title, int height, int weight) {
                this(title, new Dimension(weight, height));
        }

        /**
         * Initialize panel components.
         */
        private void initComponents() {
                setLayout(new BorderLayout());
                labelPanelTitle = new Label(title, Label.CENTER);
                labelPanelTitle.setBackground(Color.BLACK);
                labelPanelTitle.setForeground(Color.WHITE);
                add(labelPanelTitle, BorderLayout.NORTH);
                panelContent = new Panel();
                add(panelContent, BorderLayout.CENTER);
        }

        /**
         * Attach components to the panel.
         * @param panel Panel
         * @param c Component
         * @param gridx Specifies the cell containing the leading corner of the component's display area, where the cell at the origin of the grid has address gridx = 0, gridy = 0.
         * @param gridy Specifies the cell containing the leading corner of the component's display area, where the cell at the origin of the grid has address gridx = 0, gridy = 0.
         * @param gridwidth Specifies the number of cells in a row (for gridwidth) or column (for gridheight) in the component's display area. The default value is 1.
         * @param gridheight Specifies the number of cells in a row (for gridwidth) or column (for gridheight) in the component's display area. The default value is 1. 
         * @see
         */
        public void attachComponent(Component c, int gridx, int gridy, int gridwidth, int gridheight) {
                GridBagConstraints constraint = new GridBagConstraints();
                constraint.gridx = gridx;
                constraint.gridy = gridy;
                constraint.gridwidth = gridwidth;
                constraint.gridheight = gridheight;
                constraint.fill = GridBagConstraints.BOTH;
                constraint.insets = new Insets(4, 4, 4, 4);
                constraint.weightx = 1.0;
                constraint.weighty = 1.0;
                panelContent.add(c);
                GridBagLayout layout = new GridBagLayout();
                panelContent.setLayout(layout);
                layout.setConstraints(c, constraint);
        }

}
